home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!usenet
- From: GHouck <hksys@teleport.com>
- Newsgroups: comp.lang.c
- Subject: Re: HELP: Illegal Pointer Arithmetic
- Date: 23 Feb 1996 21:37:01 GMT
- Organization: systems hk
- Message-ID: <4glc1t$ovu@maureen.teleport.com>
- References: <4gj0ug$730@news.one.net>
- NNTP-Posting-Host: ip-pdx04-40.teleport.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- Oren Levin <oren@one.net> wrote:
- >I was wondering if someone could help me. I'm in the midst of learning
- >C/C++ and am trying to program the examples in Andrew Birnstock and John
- >Rex's book "Practical Algorithyms for Programers." I am using Symentec's
- >Think C++ (v 6 - Mac).
- >The following code is giving me a "illegal pointer arithmetic" error.
- >I'm trying to strip the carrage return off of a line of text read from a
- >file.
- >
- >TIA for the help.
- >Oren Levin
- >oren@one.net
- >
- >=== code snippet ===
- > while (! feof (fin))
- > {
- > /* read a record */
- > if (fgets (buffer, 127, fin) == NULL)
- > break;
- >
- > /* get rid of the trailing carrage return */
- > buffer [strlen (buffer) - 1] = "\0";
- Oren,
- Instead of assigning "\0" as your trailing NULL, you should be
- assigning a single character: '\0'.
- Yours, Geoff Houck
-
-
-